package cn.stimd.spring.beans.factory.config;

import cn.stimd.spring.beans.BeansException;
import cn.stimd.spring.beans.TypeConverter;
import cn.stimd.spring.beans.factory.BeanFactory;
import cn.stimd.spring.beans.factory.support.RootBeanDefinition;
import org.springframework.util.StringValueResolver;

/**
 * Created by Stimd
 * 项目地址：https://gitee.com/stimd/spring-wheel
 * 公众号：Java编程探微
 */
public interface ConfigurableBeanFactory extends AutowireCapableBeanFactory, SingletonBeanRegistry{
    void setParentBeanFactory(BeanFactory parentBeanFactory) throws IllegalStateException;

    TypeConverter getTypeConverter();

    RootBeanDefinition getMergedBeanDefinition(String beanName) throws BeansException;

    /**
     * 添加Bean后置处理器
     */
    void addBeanPostProcessor(BeanPostProcessor beanPostProcessor);
    int getBeanPostProcessorCount();

    /**
     * 嵌入值解析器
     */
    void addEmbeddedValueResolver(StringValueResolver valueResolver);
    boolean hasEmbeddedValueResolver();
    String resolveEmbeddedValue(String value);

    /**
     * 销毁单例Bean
     */
    void destroySingletons();

    // ------------------------------- ConfigurableListableBeanFactory接口
    /**
     * 注册用于依赖注入的候选Bean
     */
    void registerResolvableDependency(Class<?> dependencyType, Object autowiredValue);

    /**
     * 确保实例化所有的单例Bean（非懒加载），包括FactoryBean
     */
    void preInstantiateSingletons();

    /**
     * 根据Bean名称获取BeanDefinition
     */
    BeanDefinition getBeanDefinition(String beanName);
}
